<template>
  <view class="operate-wrapper flex flex-row around">
    <view class="operate" v-for="(item, index) in operateList" :key="index" v-if="item.show" @click="itemClick(item)">
      <button class="operate-item flex flex-column justify-center item-center"
        :openType="item.label === '分享' ? 'share' : ''" plain>
        <image :src="item.icon" />
        <text>{{ item.label }}</text>
      </button>
    </view>
  </view>
</template>
<script>
export default {
  name: "Operate",
  props: {
    isShowWin: {
      default: false,
      type: Boolean
    },
    uuid: {
      type: String,
      required: true
    },
    practiceType: {
      type: String,
      default: '1'
    }
  },
  computed: {
    operateList() {
      return [
        {
          label: "练习设置",
          icon: "https://qiniu-bjjrzy.bjjrzy.com/bjupi/practice/cognPractice/improve/operate/set.svg",
          path: "/improve/publish/practiceSettings",
          show: true,
        },
        {
          label: "成绩统计",
          icon: "https://qiniu-bjjrzy.bjjrzy.com/bjupi/practice/cognPractice/improve/operate/statistics.svg",
          path: "",
          show: true,
        },
        {
          label: "获奖名单",
          icon: "https://qiniu-bjjrzy.bjjrzy.com/bjupi/practice/cognPractice/improve/operate/win.svg",
          path: "",
          show: this.practiceType == '4',
        },
        {
          label: "分享",
          icon: "https://qiniu-bjjrzy.bjjrzy.com/bjupi/practice/cognPractice/improve/operate/share.svg",
          path: "",
          show: true,
        }
      ]
    }
  },
  methods: {
    itemClick(item) {
      if (item.label === "练习设置") {
        uni.navigateTo({
          url: `${item.path}?upgPracticeUuid=${this.uuid}&practiceType=${this.practiceType}`
        })
      }
      if (item.label === "成绩统计") {
        if (this.practiceType == '1' || this.practiceType == '3') {
          //每天一练
          uni.navigateTo({
            url: `/improve/publish/scoreStatistics/practiceIndex?upgPracticeUuid=${this.uuid}&practiceType=${this.practiceType}`
          })
        }
        if (this.practiceType == '2' || this.practiceType == '4') {
          //在线练测
          uni.navigateTo({
            url: `/improve/publish/scoreStatistics/practiceUser?upgPracticeUuid=${this.uuid}&practiceType=${this.practiceType}`
          })
        }
      }
      if (item.label === "获奖名单") {
        uni.navigateTo({
          url: `/improve/publish/winAward/index?upgPracticeUuid=${this.uuid}&practiceType=${this.practiceType}`
        })
      }
    }
  },
}
</script>
<style scoped lang="scss">
.operate-wrapper {
  box-shadow: 1px 1px 4px 2px rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  width: calc(100% - 30px);
  margin-top: 50px;
  background-color: #fff;
  padding: 12px 0;
  margin-left: 15px;

  .operate-item {
    border: none;
    outline: none;
    padding: 0;
    margin: 0;
    line-height: 1;

    image {
      width: 32px;
      height: 32px;
    }

    text {
      font-size: 12px;
      color: #333333;
      margin-top: 5px;
    }
  }
}
</style>